xquery version "1.0";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace xs="http://www.w3.org/2001/XMLSchema";

let $myint := request:get-parameter("myint",0)
let $myint := if ($myint castable as  xs:integer)
              then xs:integer($myint)
              else 0
let $mydecimal := request:get-parameter("mydecimal", 0.0)
let $mydecimal := if ($mydecimal castable as  xs:decimal)
                  then xs:decimal($mydecimal)
                  else 0.0

let $test := request:get-parameter("test","")

let $binary := util:binary-doc('/db/nodes/333-214/data/2012/06/14/333-214-data-1339676346441')
let $input := util:binary-to-string($binary)

return
<results>
   <message>Got test: {$test}, myint: {$myint} and  mydecimal: {$mydecimal} </message>
   <m>input : {$input}</m>
</results>
